<template>
  <div style="height: 100%; width: 100%; position: relative; overflow: hidden">
      <div class="page-top" style="border: 1px solid #ccc">
          <div style="width: 100%; height: 100%">
              <table style="width: 100%; font-size: 12px; border-spacing: 5px">
                  <tr>
                      <td width="60" align="right">标本日期</td>
                      <td>
                          <el-date-picker v-model="searchParam.sampledate" type="date" placeholder="选择日期"
                              style="width: 160px" value-format="yyyy-MM-dd"></el-date-picker>
                      </td>
                      <td width="60" align="right">报告单元</td>
                      <td>
                          <rm-ddl-rptunit prgno="LIS325" v-model="searchParam.rptunitid" filterable defaultflag="1"
                              clearable @change="handlerrptitemchange($event)" :appendtobody="true"
                              visible-change:true wi></rm-ddl-rptunit>
                      </td>
                      <td width="60" align="right">标本号</td>
                      <td>
                          <el-input v-model="searchParam.sampleno" placeholder="请输入样本号" style="width: 100%">
                          </el-input>
                      </td>
                      <td colspan="2">
                          <el-checkbox v-model="searchParam.pat_noflag" true-label="1" false-label="0"
                              style="margin-left: 10px">病历号为空</el-checkbox>
                      </td>
                  </tr>
                  <tr>
                      <td align="right">病人来源</td>
                      <td width="225" style="display: flex">
                          <rm-ddl-common datatype="seccode" kindno="PT" dataname="病人来源"
                              v-model="searchParam.pat_typecode" width="160" style="margin-right: 10px">
                          </rm-ddl-common>
                          <el-button @click.native="multiFun('pat')" style="background-color: #e6e6e6; color: black">
                              多选</el-button>
                      </td>
                      <td width="80" align="right">申请科室</td>
                      <td width="225" style="display: flex">
                          <rm-ddl-common datatype="dept" dataname="科室" v-model="searchParam.req_deptno" width="160"
                              style="margin-right: 10px"></rm-ddl-common>
                          <el-button @click.native="multiFun('dept')" style="background-color: #e6e6e6; color: black">
                              多选</el-button>
                      </td>
                      <td></td>
                      <td width="220" align="left">
                          <el-radio-group v-model="searchParam.print_count">
                              <el-radio label="All">全部</el-radio>
                              <el-radio label="0">未打印</el-radio>
                              <el-radio label="1">已打印</el-radio>
                          </el-radio-group>
                      </td>
                      <td colspan="2">
                          <el-checkbox v-model="searchParam.pat_nameflag" true-label="1" false-label="0"
                              style="margin-left: 10px">姓名为空</el-checkbox>
                      </td>
                  </tr>
                  <tr>
                      <td colspan="7"></td>
                      <td width="500" align="right">
                          <el-button type="primary" @click="queryLabReport" icon="el-icon-search">查询</el-button>
                          <el-button @click.native="btnSavemod" style="background-color: #e6e6e6; color: black">保存
                          </el-button>
                      </td>
                  </tr>
              </table>
          </div>
      </div>
      <div class="pagecenter">
          <div style="height: 99%; width: 100%">
              <vxe-table ref="xTable" :data.sync="labReportList" :loading="labReportLoading" show-overflow
                  height="auto" :select-config="{ reserve: true }" border size="mini"
                  :mouse-config="{ selected: true }" show-header-overflow highlight-current-row hearder-align="center"
                  resizable stripe
                  :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true, showIcon: false, autoClear: false }"
                  @current-change="currentChangeEvent" @edit-actived="EditActive">
                  <vxe-table-column field="sampledate" title="标本日期" :formatter="['toDateString', 'yyyy-MM-dd']"
                      width="100px" align="center"></vxe-table-column>
                  <vxe-table-column field="sampleno" title="标本编号" width="100px" align="center"></vxe-table-column>
                  <vxe-table-column field="pat_no" title="病人号" width="100px"></vxe-table-column>
                  <vxe-table-column field="pat_name" title="病人姓名" width="80px" align="center"></vxe-table-column>
                  <vxe-table-column field="cp_select" title="选择" width="60px" align="center" hearder-align="center">
                      <template v-slot="{ row }">
                          <el-checkbox true-label="1" false-label="0" v-model="row.cp_select"></el-checkbox>
                      </template>
                  </vxe-table-column>
                  <vxe-table-column field="pat_sexname" title="性别" width="60px" align="center"
                      :edit-render="{ name: 'input', autoselect: true }">
                      <template v-slot:edit="{ row }">
                          <rm-ddl-common datatype="seccode" kindno="SX" v-model="row.pat_sex" width="100%"
                              :append-to-body="true" @change="ddlChange"></rm-ddl-common>
                      </template>
                  </vxe-table-column>
                  <vxe-table-column field="pat_typecodename" title="病人类别" width="100px"
                      :edit-render="{ name: 'input', autoselect: true }" align="center">
                      <template v-slot:edit="{ row }">
                          <rm-ddl-common datatype="seccode" kindno="PT" v-model="row.pat_typecode" width="100%"
                              @change="ddlChange"></rm-ddl-common>
                      </template>
                  </vxe-table-column>
                  <vxe-table-column field="specimen_codename" title="标本类型" width="120px"
                      :edit-render="{ name: 'input', autoselect: true }" align="center">
                      <template v-slot:edit="{ row }">
                          <rm-ddl-common datatype="specimen" v-model="row.specimen_code" width="100%"
                              @change="ddlChange"></rm-ddl-common>
                      </template>
                  </vxe-table-column>
                  <vxe-table-column field="specimen_comm" title="标本状态" width="80px"
                      :edit-render="{ name: 'input', autoselect: true, events: { change: inputchangeevent, blur: EClose } }"
                      align="center"></vxe-table-column>
                  <vxe-table-column field="sampled_dt" title="采样时间" width="185px" sortable align="center"
                      :edit-render="{ name: 'input', autoselect: true, events: { change: sampleddtChange, blur: EClose } }">
                      <template v-slot:edit="{ row }">
                          <el-date-picker v-model="row.sampled_dt" type="datetime" placeholder="采样时间"
                              value-format="yyyy-MM-dd HH:mm:ss" clearable style="width: 100%"
                              @change="sampleddtChange"></el-date-picker>
                      </template>
                  </vxe-table-column>
                  <vxe-table-column field="input_dt" title="录入时间" width="185px" sortable align="center"
                      :edit-render="{ name: 'input', autoselect: true, events: { change: inputdtChange, blur: EClose } }">
                      <template v-slot:edit="{ row }">
                          <el-date-picker v-model="row.input_dt" type="datetime" placeholder="录入时间"
                              value-format="yyyy-MM-dd HH:mm:ss" clearable style="width: 100%"
                              @change="inputdtChange"></el-date-picker>
                      </template>
                  </vxe-table-column>
                  <vxe-table-column field="report_commname" title="报告备注" width="120px"
                      :edit-render="{ name: 'input', autoselect: true }" align="center">
                      <template v-slot:edit="{ row }">
                          <el-input size="small" style="width:100%;" v-model="row.report_commname"
                              @dblclick.native="reportcommDlg = true" placeholder="手工输入 | 双击开窗" @change="ddlChange">
                          </el-input>
                          <!-- <rm-ddl-common datatype="seccode" kindno="reportcomm" v-model="row.report_comm" width="100%" @change="ddlChange"></rm-ddl-common> -->
                      </template>
                  </vxe-table-column>
                  <vxe-table-column field="req_reason" title="检验目的" width="120px"
                      :edit-render="{ name: 'input', autoselect: true }" align="center">
                      <template v-slot:edit="{ row }">
                          <el-input size="small" style="width:100%;" v-model="row.req_reason" placeholder="手工输入"
                              @change="ddlChange">
                          </el-input>
                      </template>
                  </vxe-table-column>
                  <vxe-table-column field="lab_advice" title="实验意见" width="120px"
                      :edit-render="{ name: 'input', autoselect: true }" align="center">
                      <template v-slot:edit="{ row }">
                          <el-input size="small" style="width:100%;" @change="ddlChange" v-model="row.lab_advice"
                              @dblclick.native="openAdviceFloatDlg(row)" placeholder="手工输入 | 双击开窗"></el-input>
                      </template>
                  </vxe-table-column>
                  <vxe-table-column field="report_username" title="检验者" width="80px"
                      :edit-render="{ name: 'input', autoselect: true }">
                      <template v-slot:edit="{ row }">
                          <rm-ddl-common datatype="reportuser" v-model="row.report_user" width="100%"
                              @change="ddlChange"></rm-ddl-common>
                      </template>
                  </vxe-table-column>
                  <vxe-table-column field="rechk_username" title="审核者" width="100px"
                      :edit-render="{ name: 'input', autoselect: true }" align="center">
                      <template v-slot:edit="{ row }">
                          <rm-ddl-common datatype="userinfo" v-model="row.rechk_user" width="100%"
                              @change="ddlChange"></rm-ddl-common>
                      </template>
                  </vxe-table-column>
                  <vxe-table-column field="charge_typenoname" title="收费类别" width="70px"
                      :edit-render="{ name: 'input', autoselect: true }" align="center">
                      <template v-slot:edit="{ row }">
                          <rm-ddl-common datatype="chargetype" v-model="row.charge_typeno" width="100%">
                          </rm-ddl-common>
                      </template>
                  </vxe-table-column>
                  <vxe-table-column field="req_deptnoname" title="申请科室" width="120px"
                      :edit-render="{ name: 'input', autoselect: true }" align="center">
                      <template v-slot:edit="{ row }">
                          <rm-ddl-common datatype="dept" v-model="row.req_deptno" width="100%" @change="ddlChange">
                          </rm-ddl-common>
                      </template>
                  </vxe-table-column>
                  <vxe-table-column field="req_wardnoname" title="病人病区" width="100px"
                      :edit-render="{ name: 'input', autoselect: true }" align="center">
                      <template v-slot:edit="{ row }">
                          <rm-ddl-common datatype="ward" v-model="row.req_wardno" width="100%" @change="ddlChange">
                          </rm-ddl-common>
                      </template>
                  </vxe-table-column>
                  <vxe-table-column field="req_docnoname" title="申请医生" width="120px"
                      :edit-render="{ name: 'input', autoselect: true }" align="center">
                      <template v-slot:edit="{ row }">
                          <rm-ddl-common datatype="doctor" v-model="row.req_docno" width="100%" @change="ddlChange">
                          </rm-ddl-common>
                      </template>
                  </vxe-table-column>
                  <vxe-table-column field="req_bedno" title="床号" width="80px"
                      :edit-render="{ name: 'input', autoselect: true, events: { change: inputchangeevent, blur: EClose } }"
                      align="center"></vxe-table-column>
                  <vxe-table-column field="pat_diagname" title="临床诊断" width="120px"
                      :edit-render="{ name: 'input', autoselect: true }" align="center">
                      <template v-slot:edit="{ row }">
                          <rm-ddl-common datatype="diagnose" v-model="row.pat_diag" width="100%" @change="ddlChange">
                          </rm-ddl-common>
                      </template>
                  </vxe-table-column>
                  <vxe-table-column field="pat_diag_icd" title="诊断Icd10" width="100px" align="center">
                  </vxe-table-column>
                  <vxe-table-column field="reserve1" title="备用1" width="80px"
                      :edit-render="{ name: 'input', autoselect: true, events: { change: inputchangeevent, blur: EClose } }"
                      align="center"></vxe-table-column>
                  <vxe-table-column field="reserve2" title="备用2" width="80px"
                      :edit-render="{ name: 'input', autoselect: true, events: { change: inputchangeevent, blur: EClose } }"
                      align="center"></vxe-table-column>
                  <vxe-table-column field="reserve3" title="备用3" width="80px"
                      :edit-render="{ name: 'input', autoselect: true, events: { change: inputchangeevent, blur: EClose } }"
                      align="center"></vxe-table-column>
                  <vxe-table-column field="reserve4" title="备用4" width="80px"
                      :edit-render="{ name: 'input', autoselect: true, events: { change: inputchangeevent, blur: EClose } }"
                      align="center"></vxe-table-column>
                  <vxe-table-column field="reserve5" title="备用5" width="80px"
                      :edit-render="{ name: 'input', autoselect: true, events: { change: inputchangeevent, blur: EClose } }"
                      align="center"></vxe-table-column>
              </vxe-table>
          </div>
      </div>
      <!--病人来源多选-->
      <el-dialog title="病人来源多选" :visible.sync="multiPatsourceVisible" width="920px" v-el-drag-dialog
          :close-on-click-modal="false">
          <!-- <rm-transfer v-model="multiPatsource" :leftTableData="leftOptionPat" :rightTableData="rightOptionPat" @change="closedialog" name="pat"></rm-transfer> -->
          <rm-SqlMultiple v-model="multiPatsource" :leftOption="leftOptionPat" :rightOption="rightOptionPat"
              @change="closedialog" name="pat"></rm-SqlMultiple>
      </el-dialog>
      <!--申请科室多选-->
      <el-dialog title="申请科室多选" :visible.sync="reqDeptVisible" width="920px" v-el-drag-dialog
          :close-on-click-modal="false">
          <rm-SqlMultiple v-model="reqDept" :leftOption="leftOptionDept" :rightOption="rightOptionDept"
              @change="closedialog" name="dept"></rm-SqlMultiple>
      </el-dialog>
      <el-dialog title="性别选择" :visible.sync="sexDialogVisible" width="900px">
          <rm-pop-common datatype="seccode" kindno="SX" dataname="性别选择" v-model="sexval" @change="sexchange"
              @cancel="fieldCancel(1)" width="100%"></rm-pop-common>
      </el-dialog>
      <el-dialog title="病人类别选择" :visible.sync="patTypeDialogVisible" width="900px">
          <rm-pop-common datatype="seccode" kindno="PT" dataname="病人类别选择" v-model="patTypeval" @change="pattypechange"
              @cancel="fieldCancel(2)" width="100%"></rm-pop-common>
      </el-dialog>
      <el-dialog title="标本类型选择" :visible.sync="specimenDialogVisible" width="900px">
          <rm-pop-common datatype="specimen" dataname="标本类型" v-model="specimenval" @change="specimenchange"
              @cancel="fieldCancel(3)" width="100%"></rm-pop-common>
      </el-dialog>
      <el-dialog title="报告备注选择" :visible.sync="reportCommDialogVisible" width="900px">
          <rm-pop-common datatype="seccode" kindno="ReportComm" dataname="报告备注选择" v-model="reportCommval"
              @change="reportcommvalchange" @cancel="fieldCancel(4)" width="100%"></rm-pop-common>
      </el-dialog>
      <el-dialog title="收费类别选择" :visible.sync="dcChargetypeDialogVisible" width="900px">
          <rm-pop-common datatype="chargetype" dataname="收费类别选择" v-model="chargeval" @change="chargeConfirm"
              @cancel="fieldCancel(6)" width="100%"></rm-pop-common>
      </el-dialog>
      <el-dialog title="科室代码选择" :visible.sync="deptDialogVisible" width="900px">
          <rm-pop-common datatype="dept" dataname="科室" v-model="deptval" @change="deptConfirm"
              @cancel="fieldCancel(7)" width="100%"></rm-pop-common>
      </el-dialog>
      <el-dialog title="病区代码选择" :visible.sync="wardDialogVisible" width="900px">
          <rm-pop-common datatype="ward" dataname="病区" v-model="wardval" @change="wardConfirm"
              @cancel="fieldCancel(8)" width="100%"></rm-pop-common>
      </el-dialog>
      <el-dialog title="临床诊断选择" :visible.sync="dcDiagnoseDialogVisible" width="900px">
          <rm-pop-common datatype="diagnose" dataname="临床诊断选择" v-model="diagnoseval" @change="diagnoseConfirm"
              @cancel="fieldCancel(9)" width="100%"></rm-pop-common>
      </el-dialog>
      <el-dialog title="申请医生选择" :visible.sync="doctorDialogVisible" width="900px">
          <rm-pop-common datatype="doctor" dataname="医生" v-model="req_docname" @change="doctorConfirm"
              @cancel="fieldCancel(10)" width="100%"></rm-pop-common>
      </el-dialog>
      <!-- 标本状态、实验室意见、床号、备用 -->
      <el-dialog :title="otherDialogList[nowOtherIndex].title" :visible.sync="otherDialogVisible" width="900px">
          <div class="dialog-textarea" style="margin-top: 10px; height: 350px; width: 100%">
              <el-input type="textarea" v-model="otherDialogText" style="height: 100%; width: 100%"></el-input>
          </div>
          <div class="dialog-button">
              <el-button @click="fieldConfirm(5)" icon="el-icon-circle-check">确定</el-button>
              <el-button @click="fieldCancel(5)" icon="el-icon-circle-close">取消</el-button>
          </div>
      </el-dialog>
      <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="请选择备注"
          :visible.sync="reportcommDlg">
          <rm-pop-common ref="popcom" @change="reportcommchange" @cancel="reportcommDlg = false;" kindno="reportcomm"
              datatype="seccode"></rm-pop-common>
      </el-dialog>
      <!-- 登录 -->
      <el-dialog title="用户登录" :visible.sync="checkDialogVisible" width="450px">
          <div class="dialog-textarea" style="margin-top: 10px; width: 100%">
              <el-form :model="ruleForm" class="ms-content" label-width="0px" ref="ruleForm">
                  <el-form-item prop="userno">
                      <el-row>
                          <el-col align="right" :span="6">
                              <div class="grid-content">用户代码：</div>
                          </el-col>
                          <el-col :span="16">
                              <div class="grid-content">
                                  <el-input placeholder="请输入用户名" v-model="loginForm.userno" ref="lguname"
                                      @keyup.enter.native="inputautofocus('lguname')"> </el-input>
                              </div>
                          </el-col>
                      </el-row>
                  </el-form-item>
                  <el-form-item prop="username">
                      <el-row>
                          <el-col align="right" :span="6">
                              <div class="grid-content">登录者姓名：</div>
                          </el-col>
                          <el-col :span="16">
                              <div class="grid-content">
                                  <el-input placeholder="" v-model="loginForm.username" disabled></el-input>
                              </div>
                          </el-col>
                      </el-row>
                  </el-form-item>
                  <el-form-item prop="password">
                      <el-row>
                          <el-col align="right" :span="6">
                              <div class="grid-content">密&nbsp;&nbsp;&nbsp;码：</div>
                          </el-col>
                          <el-col :span="16">
                              <div class="grid-content">
                                  <el-input placeholder="请输入密码" type="password" v-model="loginForm.password"
                                      @keyup.enter.native="inputautofocus('lgupwd')" ref="lgupwd"> </el-input>
                              </div>
                          </el-col>
                      </el-row>
                  </el-form-item>
              </el-form>
          </div>
          <div class="dialog-button">
              <el-button @click="fieldConfirm(11)" icon="el-icon-circle-check">确定</el-button>
              <el-button @click="fieldCancel(11)" icon="el-icon-circle-close">取消</el-button>
          </div>
      </el-dialog>
      <!--检验意见悬浮窗--->
      <rm-floatwindow v-rm-drag-window :visible="dialogAdvicefloatwindowVisible" :winStyle="floatwindowstyle3"
          title="实验意见" @close="FloatClose()">
          <div>
              <el-input type="textarea" :rows="6" v-model="txtadvice"></el-input>
          </div>
          <div style="height: calc(100% - 130px)">
              <table style="width: 100%; border-spacing: 0px; margin-top: 5px; height: 100%">
                  <tr>
                      <td>
                          快速查找
                          <el-input v-model="advicesearchtxtFloat" @input="AdviceSearchFloat" placeholder="请输入要查找的信息"
                              style="width: calc(100% - 60px)"></el-input>
                      </td>
                      <td>
                          <el-button @click.native="btnadvicesearchsave" type="primary">确定</el-button>
                      </td>
                  </tr>
                  <tr>
                      <td style="height: 100%">
                          <vxe-table :data="tableDataAdvice" :loading="loadingAdvice" @cell-click="AdviceFloatClick"
                              @cell-dblclick="AdviceFloatdblClick" height="180px" highlight-current-row
                              highlight-hover-row resizable highlight-hover-column border
                              show-header-overflow="tooltip" show-overflow="tooltip" header-align="center" size="mini"
                              stripe width="auto">
                              <vxe-table-column field="txttitle" title="标题" width="100px"></vxe-table-column>
                              <vxe-table-column field="txtinfo" title="文字描述" width="160px"></vxe-table-column>
                              <vxe-table-column field="seq" title="序号" width="80px"></vxe-table-column>
                              <vxe-table-column field="inputcode" title="输入码" width="80px"></vxe-table-column>
                          </vxe-table>
                      </td>
                      <td width="100">
                          <div style="margin-left: 15px; width: 200px; height: calc(100% - 30px)">
                              <el-checkbox v-model="appendChangeRowFloat" style="margin-top: 20px; display: block">
                                  追加时自动换行</el-checkbox>
                              <div style="margin-top: 20px">
                                  <span style="color: blue">说明:<br />单击为追加<br />双击为替换</span>
                              </div>
                          </div>
                      </td>
                  </tr>
              </table>
          </div>
      </rm-floatwindow>
  </div>
</template>

<script>
import XEUtils from "xe-utils";
export default {
  name: "LIS325",
  data() {
      return {
          searchParam: {
              sampledate: XEUtils.toDateString(new Date(), "yyyy-MM-dd"),
              print_count: "0",
          },
          labReportList: [],
          labReportLoading: false,
          selrow: {},
          multiPatsource: "",
          multiPatsourceVisible: false,
          leftOptionPat: [],
          rightOptionPat: [],
          reqDept: "",
          reqDeptVisible: false,
          leftOptionDept: [],
          rightOptionDept: [],
          popSelrow: {},
          sexDialogVisible: false,
          sexval: "",
          patTypeDialogVisible: false,
          patTypeval: "",
          specimenDialogVisible: false,
          specimenList: [],
          specimenval: "",
          reportCommDialogVisible: false,
          reportCommval: "",
          otherDialogList: [
              { title: "标本状态", value: "specimen_comm" },
              { title: "实验室意见", value: "lab_advice" },
              { title: "床号", value: "req_bedno" },
              { title: "备用1", value: "reserve1" },
              { title: "备用2", value: "reserve2" },
              { title: "备用3", value: "reserve3" },
              { title: "备用4", value: "reserve4" },
              { title: "备用5", value: "reserve5" },
          ],
          nowOtherIndex: 0,
          otherDialogText: "",
          // dialogTitle: '标本状态',
          otherDialogVisible: false,
          dcChargetypeDialogVisible: false,
          chargeval: "",
          deptDialogVisible: false,
          deptval: "",
          wardDialogVisible: false,
          wardval: "",
          doctorDialogVisible: false,
          req_docname: "",
          dcDiagnoseDialogVisible: false,
          diagnoseval: "",
          checkDialogVisible: false,
          checkType: 1,
          loginForm: {},
          ruleForm: {
              userno: "",
              password: "",
          },
          //当前激活列
          ActCol: "",
          reportcommDlg: false,
          dialogAdvicefloatwindowVisible: false, //检验意见浮动窗口显示标志
          floatwindowstyle3: "top:100px;left:calc(50% + 40px );width:650px;height:400px", //检验意见浮动窗口回传样式
          txtadvice: "", //检验意见悬浮窗文字
          advicesearchtxtFloat: "", //检验意见浮动窗口关键词查询
          tableDataAdvice: [], //报告文字描述结果显示数据
          tableDataAdviceAll: [], //报告文字描述结果全部数据
          InputCodeArr: [], //ddl数据列表
          loadingAdvice: false, //报告文字描述结果加载标志
          appendChangeRowFloat: false, //检验意见浮动窗口追加行标志
      };
  },
  mounted() {
      this.initOption();
  },
  methods: {
      btnadvicesearchsave() {
          console.log("🚸 —— this.lab_advice", this.txtadvice);
          this.ddlChange(this.txtadvice);
          this.FloatClose();
      },
      FloatClose() {
          this.dialogAdvicefloatwindowVisible = false;
      },
      openAdviceFloatDlg(row) {
          this.dialogAdvicefloatwindowVisible = true;
          this.txtadvice = row.lab_advice;
      },
      AdviceFloatdblClick({ row }) {
          this.txtadvice = row.txtinfo;
          // this.PatientInfo[this.popdatatype.replace("LIS3_", "")] = row.txtinfo;
      },
      AdviceFloatClick({ row }) {
          if (this.txtadvice) {
              if (this.txtadvice.indexOf(row.txtinfo) == -1) {
                  if (this.appendChangeRowFloat) {
                      this.txtadvice += "\n" + row.txtinfo;
                      // this.PatientInfo[this.popdatatype.replace("LIS3_", "")] += "\n" + row.txtinfo;
                  } else {
                      if (this.txtadvice) {
                          this.txtadvice += "," + row.txtinfo;
                          // this.PatientInfo[this.popdatatype.replace("LIS3_", "")] += "," + row.txtinfo;
                      } else {
                          this.txtadvice += row.txtinfo;
                          // this.PatientInfo[this.popdatatype.replace("LIS3_", "")] += row.txtinfo;
                      }
                  }
              }
          } else {
              this.txtadvice = row.txtinfo;
              // this.PatientInfo[this.popdatatype.replace("LIS3_", "")] = row.txtinfo;
          }
      },
      AdviceSearchFloat(value) {
          if (value) {
              this.tableDataAdvice = this.tableDataAdviceAll.filter((item) => item.txttitle.toUpperCase().indexOf(value.toUpperCase()) > -1 || item.txtinfo.toUpperCase().indexOf(value.toUpperCase()) > -1 || item.inputcode.toUpperCase().indexOf(value.toUpperCase()) > -1);
          } else {
              this.tableDataAdvice = XEUtils.clone(this.tableDataAdviceAll, true);
          }
      },
      QueryAdvice() {
          this.$tool
              .request({
                  url: "LIS/LIS3/LIS310",
                  method: "post",
                  data: {
                      action: "getrptunittxtinfo",
                      rptunitid: this.searchParam.rptunitid,
                      infotype: "0",
                  },
              })
              .then((res) => {
                  if (!res.hasOwnProperty("errcode")) {
                      this.tableDataAdviceAll = XEUtils.clone(res, true);
                      this.tableDataAdvice = res;
                  }
              });
      },
      reportcommchange(c, v) {
          // this.sel_reportcomm = v;
          this.ddlChange(v, v);
          this.reportcommDlg = false;
      },
      initOption() {
          this.$tool
              .request({
                  url: "LIS/LIS3/LIS325",
                  method: "post",
                  data: {
                      action: "initOption",
                      prgno: "LIS325",
                  },
              })
              .then((response) => {
                  this.searchParam.rptunitid = response.defrptunitid;
                  this.leftOptionDept = response.deptOption;
                  this.leftOptionPat = response.pattypeOption;
              });
          //无用代码删除  
          // this.$tool.request({
          //     url: "ucent/ddl",
          //     method: "post",
          //     data: {
          //         action: "specimen", // 标本类型
          //         rptunitid: this.selrow.rptunitid
          //     }
          // }).then(response => {
          //     this.specimenList = response.Data;
          // });
          // this.$tool.request({
          //     url: "ucent/ddl",
          //     method: "post",
          //     data: {
          //         action: "dept", // 申请科室
          //     }
          // }).then(response => {
          //     this.deptList = response.Data;
          // })
          // this.$tool.request({
          //     url: "ucent/ddl",
          //     method: "post",
          //     data: {
          //         action: "ward", // 病区
          //     }
          // }).then(response => {
          //     this.wardList = response.Data;
          // })
      },
      queryLabReport() {
          this.labReportLoading = true;
          this.$tool
              .request({
                  url: "LIS/LIS3/LIS325",
                  method: "post",
                  data: {
                      action: "querylabreport",
                      ...this.searchParam,
                  },
              })
              .then((response) => {
                  if (response.Data.length > 0) {
                      response.Data.forEach((element) => {
                          element.cp_select = "1";
                      });
                  }
                  this.labReportList = response.Data;
                  this.QueryAdvice();
                  this.labReportLoading = false;
              });
      },
      handlerrptitemchange(e) {
          this.searchParam.rptunitid = e;
      },
      async init() {
          const res = await this.$tool.request({
              url: "LIS/LIS3/LIS325",
              method: "post",
              data: {
                  action: "init",
              },
          });
          this.leftOptionDept = res.deptOption;
          this.leftOptionPat = res.pattypeOption;
      },
      //多选按钮
      async multiFun(type) {
          if (type == "pat") {
              await this.init();
              this.rightOptionPat = [];
              if (this.multiPatsource != "") {
                  let k = this.multiPatsource.split(",");
                  k.forEach((item) => {
                      let ndata = this.leftOptionPat.find((m) => m.data == item);
                      this.rightOptionPat.push(ndata);
                  });
              }
              this.multiPatsourceVisible = true;
          } else {
              await this.initOption();
              console.log("this.leftOptionDept", this.leftOptionDept);
              this.rightOptionDept = [];
              if (this.reqDept != "") {
                  let k = this.reqDept.split(",");
                  k.forEach((item) => {
                      let ndata = this.leftOptionDept.find((m) => m.data == item);
                      this.rightOptionDept.push(ndata);
                  });
              }
              this.reqDeptVisible = true;
          }
      },
      //多选弹窗关闭
      closedialog(value, name) {
          if (name == "pat") {
              this.multiPatsourceVisible = false;
              this.multiPatsource = value;
              this.searchParam.pat_typecode = value;
          } else {
              this.reqDeptVisible = false;
              this.reqDept = value;
              this.searchParam.req_deptno = value;
          }
      },
      currentChangeEvent({ row, rowIndex }) {
          this.selrow = row;
          // this.querySampleInfo(row.sampleid, row.barcode);
      },
      DblEvent({ row, rowIndex, $rowIndex, column }) {
          // if (!this.editflag) return;
          switch (column.property) {
              case "pat_sexname":
                  this.sexDialogVisible = true;
                  break;
              case "pat_typename":
                  this.patTypeDialogVisible = true;
                  break;
              case "specimen_name":
                  this.specimenDialogVisible = true;
                  break;
              case "specimen_comm":
                  this.nowOtherIndex = 0;
                  this.otherDialogText = row.specimen_comm;
                  this.otherDialogVisible = true;
                  break;
              case "report_commname":
                  this.reportCommDialogVisible = true;
                  break;
              case "lab_advice":
                  this.nowOtherIndex = 1;
                  this.otherDialogText = row.lab_advice;
                  this.otherDialogVisible = true;
                  break;
              case "report_username":
                  this.checkType = 1;
                  this.loginForm = {};
                  this.checkDialogVisible = true;
                  break;
              case "rechk_username":
                  this.checkType = 2;
                  this.loginForm = {};
                  this.checkDialogVisible = true;
                  break;
              case "charge_typename":
                  this.dcChargetypeDialogVisible = true;
                  break;
              case "req_deptname":
                  this.deptDialogVisible = true;
                  break;
              case "req_wardname":
                  this.wardDialogVisible = true;
                  break;
              case "req_docname":
                  this.doctorDialogVisible = true;
                  break;
              case "req_bedno":
                  this.nowOtherIndex = 2;
                  this.otherDialogText = row.req_bedno;
                  this.otherDialogVisible = true;
                  break;
              case "pat_diagname":
                  this.dcDiagnoseDialogVisible = true;
                  break;
              case "reserve1":
                  this.nowOtherIndex = 3;
                  this.otherDialogText = row.reserve1;
                  this.otherDialogVisible = true;
                  break;
              case "reserve2":
                  this.nowOtherIndex = 4;
                  this.otherDialogText = row.reserve2;
                  this.otherDialogVisible = true;
                  break;
              case "reserve3":
                  this.nowOtherIndex = 5;
                  this.otherDialogText = row.reserve3;
                  this.otherDialogVisible = true;
                  break;
              case "reserve4":
                  this.nowOtherIndex = 6;
                  this.otherDialogText = row.reserve4;
                  this.otherDialogVisible = true;
                  break;
              case "reserve5":
                  this.nowOtherIndex = 7;
                  this.otherDialogText = row.reserve5;
                  this.otherDialogVisible = true;
                  break;
          }
      },
      fieldConfirm(type) {
          console.log(type);
          if (type == 5) {
              this.labReportList.forEach((element) => {
                  var fieldName = this.otherDialogList[this.nowOtherIndex].value;
                  console.log(fieldName);
                  element[fieldName] = this.otherDialogText;
              });
              this.otherDialogVisible = false;
          }
          if (type == 11) {
              if (this.checkType == 1) {
                  this.labReportList.forEach((element) => {
                      element.report_username = "";
                      element.report_user = "";
                  });
              }
              if (this.checkType == 2) {
                  this.labReportList.forEach((element) => {
                      element.rechk_username = "";
                      element.rechk_user = "";
                  });
              }
              this.checkDialogVisible = false;
          }
      },
      sexchange(code, name) {
          this.labReportList.forEach((element) => {
              element.pat_sex = code;
              element.pat_sexname = name;
          });
          this.sexDialogVisible = false;
      },
      pattypechange(code, name) {
          this.labReportList.forEach((element) => {
              element.pat_typecode = code;
              element.pat_typename = name;
          });
          this.patTypeDialogVisible = false;
      },
      specimenchange(code, name) {
          this.labReportList.forEach((element) => {
              element.specimen_code = code;
              element.specimen_name = name;
          });
          this.specimenDialogVisible = false;
      },
      reportcommvalchange(code, name) {
          this.labReportList.forEach((element) => {
              element.report_comm = code;
              element.report_commname = name;
          });
          this.reportCommDialogVisible = false;
      },
      chargeConfirm(code, name) {
          this.labReportList.forEach((element) => {
              element.charge_typeno = code;
              element.charge_typename = name;
          });
          this.dcChargetypeDialogVisible = false;
      },
      deptConfirm(code, name) {
          this.labReportList.forEach((element) => {
              element.req_deptno = code;
              element.req_deptname = name;
          });
          this.deptDialogVisible = false;
      },
      wardConfirm(code, name) {
          this.labReportList.forEach((element) => {
              element.req_wardno = code;
              element.req_wardname = name;
          });
          this.wardDialogVisible = false;
      },
      diagnoseConfirm(code, name, row) {
          console.log(row);
          this.labReportList.forEach((element) => {
              element.pat_diag = code;
              element.pat_diagname = name;
              element.pat_diag_icd = row.ICD10编码;
          });
          this.dcDiagnoseDialogVisible = false;
      },
      doctorConfirm(code, name) {
          this.labReportList.forEach((element) => {
              element.req_docno = code;
              element.req_docname = name;
          });
          this.doctorDialogVisible = false;
      },
      fieldCancel(type) {
          console.log(type);
          if (type == 5) {
              this.otherDialogText = "";
          } else if (type == 11) {
              this.checkDialogVisible = false;
          } else {
              this.$confirm("你是否要清空当前列的内容?", "提示", {
                  confirmButtonText: "确定",
                  cancelButtonText: "取消",
                  type: "warning",
              })
                  .then(() => {
                      // 清空
                      if (type == 1) {
                          this.labReportList.forEach((element) => {
                              element.pat_sex = "";
                              element.pat_sexname = "";
                          });
                      }
                      if (type == 2) {
                          this.labReportList.forEach((element) => {
                              element.pat_typecode = "";
                              element.pat_typename = "";
                          });
                      }
                      if (type == 3) {
                          this.labReportList.forEach((element) => {
                              element.specimen_code = "";
                              element.specimen_name = "";
                          });
                      }
                      if (type == 4) {
                          this.labReportList.forEach((element) => {
                              element.report_comm = "";
                              element.report_commname = "";
                          });
                      }
                      if (type == 6) {
                          this.labReportList.forEach((element) => {
                              element.charge_typeno = "";
                              element.charge_typename = "";
                          });
                      }
                      if (type == 7) {
                          this.labReportList.forEach((element) => {
                              element.req_deptno = "";
                              element.req_deptname = "";
                          });
                      }
                      if (type == 8) {
                          this.labReportList.forEach((element) => {
                              element.req_wardno = "";
                              element.req_wardname = "";
                          });
                      }
                      if (type == 9) {
                          this.labReportList.forEach((element) => {
                              element.pat_diag = "";
                              element.pat_diagname = "";
                              element.pat_diag_icd = "";
                          });
                      }
                      if (type == 10) {
                          this.labReportList.forEach((element) => {
                              element.req_docno = "";
                              element.req_docname = "";
                          });
                      }
                  })
                  .catch(() => { });
          }
          this.sexDialogVisible = false;
          this.patTypeDialogVisible = false;
          this.specimenDialogVisible = false;
          this.reportCommDialogVisible = false;
          this.otherDialogVisible = false;
          this.dcChargetypeDialogVisible = false;
          this.deptDialogVisible = false;
          this.wardDialogVisible = false;
          this.dcDiagnoseDialogVisible = false;
          this.doctorDialogVisible = false;
      },

      btnSavemod() {
          var datas = [];
          var updatedata = this.$refs.xTable.getUpdateRecords();
          for (let i = 0; i < updatedata.length; i++) {
              datas.push(JSON.stringify(updatedata[i].cdata));
          }
          this.$tool
              .request({
                  url: "LIS/LIS3/LIS325",
                  method: "post",
                  data: {
                      action: "save",
                      saveinfo: datas,
                  },
              })
              .then((res) => {
                  if (res.Item1 == "1") {
                      this.$message.success("保存成功");
                      this.queryLabReport();
                  } else {
                      this.$alert(res.Item2, "错误");
                  }
              });
      },

      ddlChange(c, v, row) {
          this.$refs.xTable.clearActived();
          var rows = this.$refs.xTable.afterFullData.filter((item) => item.cp_select == "1");
          for (let i = 0; i < rows.length; i++) {
              var codename = this.ActCol.substring(0, this.ActCol.length - 4);
              var codefullna = this.ActCol;
              rows[i][codename] = c;
              if (codefullna == "report_commname" || codefullna == "lab_advice" || codefullna == "req_reason") rows[i][this.ActCol] = c;
              else rows[i][this.ActCol] = v;
          }
      },
      sampleddtChange(c, v, row) {
          console.info("11111111111111111");
          var rows = this.$refs.xTable.afterFullData.filter((item) => item.cp_select == "1");
          for (let i = 0; i < rows.length; i++) {
              rows[i]["sampled_dt"] = c;
          }
      },
      inputdtChange(c, v, row) {
          var rows = this.$refs.xTable.afterFullData.filter((item) => item.cp_select == "1");
          for (let i = 0; i < rows.length; i++) {
              rows[i]["input_dt"] = c;
          }
      },
      inputchangeevent({ row }, val) {
          var rows = this.$refs.xTable.afterFullData.filter((item) => item.cp_select == "1");
          for (let i = 0; i < rows.length; i++) {
              rows[i][this.ActCol] = val.target.value;
          }
      },
      EditActive({ row, column }) {
          this.ActCol = column.property;
      },
      EClose() {
          this.$refs.xTable.clearActived();
      },
      //end
      inputautofocus(element) {
          if (element == "lguname") {
              this.$refs.lgupwd.focus();
          }
      },
  },
};
</script>

<style scoped>
.page-top {
  left: 0;
  right: 0;
  height: 98px;
  display: -webkit-box;
  -webkit-box-pack: center;
  -webkit-box-align: center;
  border: solid 1px #ccc;
  position: absolute;
  z-index: 99;
  overflow-x: auto;
  overflow-x: overlay;
  margin: 0;
  padding: 0;
  white-space: nowrap;
}

::-webkit-scrollbar {
  width: 0px;
  height: 5px;
  border: 4px solid white;
}

::-webkit-scrollbar-thumb {
  background-color: #c1c1c1;
}

::-webkit-scrollbar-track {
  background-color: #f1f1f1;
}

/* Buttons */
::-webkit-scrollbar-button:single-button {
  background-color: #bbbbbb;
  display: block;
  border-style: solid;
  height: 5px;
  width: 5px;
}

/* Left */
::-webkit-scrollbar-button:horizontal:decrement {
  margin-right: 2px;
  border-width: 4px 4px 4px 0;
  border-color: #f1f1f1 transparent #f1f1f1 #f1f1f1;
  background-color: #000000;
}

::-webkit-scrollbar-button:horizontal:decrement:hover {
  border-color: #d2d2d2 transparent #d2d2d2 #d2d2d2;
}

/* Right */
::-webkit-scrollbar-button:horizontal:increment {
  margin-left: 2px;
  border-width: 4px 0 4px 4px;
  border-color: #f1f1f1 #f1f1f1 #f1f1f1 transparent;
  background-color: #000000;
}

::-webkit-scrollbar-button:horizontal:increment:hover {
  border-color: #d2d2d2 #d2d2d2 #d2d2d2 transparent;
}

/deep/ .page-top .el-select {
  width: 160px !important;
}

.pagecenter {
  position: absolute;
  top: 103px;
  width: 100%;
  left: 0;
  bottom: 0px;
  overflow: auto;
}

.dialog-button {
  margin-top: 10px;
  text-align: center;
  display: flex;
  justify-content: flex-end;
}

/deep/ .el-radio-group {
  width: 100%;
  display: flex;
  justify-content: space-around;
}

/deep/ .dialog-textarea .el-textarea__inner {
  height: 100%;
}
</style>
